package com.woniuxy.hystrix;

import com.woniuxy.api.RemoteProductServe;
import com.woniuxy.entity.Product;
import com.woniuxy.entity.ProductDTO;
import com.woniuxy.entity.utils.ResponseEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Author: 马宇航
 * @Description: 全局降级工厂
 * @DateTime: 22/12/07/0007 16:30
 * @Component: 成都蜗牛学苑
 **/
@Component
public class FallbackFactoryCommand implements FallbackFactory<RemoteProductServe> {
    @Override
    public RemoteProductServe create(Throwable throwable) {
        return new RemoteProductServe() {
            @Override
            public ResponseEntity findOneByPid(Integer pid) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity updateProduct(Product product) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity findAllByNameOrPrice1(ProductDTO productDTO) {
                return ResponseEntity.TIMEOUT;
            }
        };
    }
}
